<template>
  <div class="box-border full">
    <div class="navbar full text-left" style="line-height: 60px;padding-left: 20px">
      <el-button type="primary" @click="$router.push('/home/addQues')">
        <i class="fa fa-plus"></i>&nbsp;添加试题
      </el-button>
      <el-button type="danger" :disabled="disabled" @click="delSelected">
        <i class="fa fa-remove"></i>&nbsp;批量删除
      </el-button>
      <el-button :disabled="disabled" @click="batchUpdate">
        <i  class="fa fa-refresh"></i>&nbsp;批量更新
      </el-button>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'Navbar',
  data () {
    return {
      activeIndex: '1'
    }
  },
  computed: {
    ...mapState({
      selectedPapers: ({ question }) => question.selectedQuestions
    }),
    disabled () {
      return !this.selectedPapers || this.selectedPapers.length === 0
    }
  },
  methods: {
    delSelected () {
      this.$store.dispatch('question/delSelected')
    },
    batchUpdate () {
      this.$bus.$emit('batch-update')
    }
  }
}
</script>
